/**
 * #smallcalendar 				data{toyear,tomonth,todate}
 * #calendar_monthcontrolbar 	data{currentyear,currentmonth}
 * #mainpart_list_content data{currentpage,year,month,date,searchcontent}
 * #cliplistrecordsstatus data{isall,istoday,date);
 * */

jQ(function(){
	jQ("div.my_clips_menu a.clipmanage").addClass("clipmanageonit");
	jQ("#left_clip_list").empty();
	jQ("input.hminput").val(0);
	var html="";
	for(var i=2020;i>=1950;i--){
		html+="<option value='"+i+"'>"+i+"</option>";
	}
	jQ("#mouth_fun_view_year").empty().append(html);
	jQ("#mainpart_list_content").data("currentpage",0);
	jQ("#mainpart_list_content").data("month",0);
	jQ("#mainpart_list_content").data("year",0);
	jQ("#mainpart_list_content").data("date",0);
	jQ("#cliplistrecordsstatus").data("isall",true)
	jQ("#titlenamelist tr").hide();
	var usertype=eval(jQ("#var_usertype").val());
	if(usertype==2){
		jQ("#clipmanagehead li[queryby='own']").siblings().hide();
		jQ("#invitecount").hide();
		jQ("#clipmanagehead li.nonequery").css("width","432px");
		jQ("#manage_search_box").hide();
		
	}
	analyzeUrl();
	getEventsByMonth(0,0,false);
	loadMainpartRecords();
	initChooseDayBtn();
	jQ("#clipmanagehead li").click(function(){
		if(eval(jQ(this).attr("enabled"))){
			if(!jQ(this).hasClass("clickon")){
				var removeclz=jQ("#clipmanagehead li.clickon").attr("queryby")+"off";
				jQ("#clipmanagehead li.clickon").removeClass().addClass(removeclz);
				var clickonclz=jQ(this).attr("clickonclz");
				jQ(this).addClass("clickon").addClass(clickonclz);
				jQ("#mainpart_list_content").data("currentpage",0);
				jQ("#titlenamelist tr").hide();
				if(clickonclz=='allon'){
					jQ("#patch_del_btn").hide().unbind("click");
					jQ("#allownshareinvite_title").show();
					jQ("#patch_cancelalert").hide().unbind("click");
				}else if(clickonclz=='ownon'){
					jQ("#patch_del_btn").show().unbind("click").bind("click",selected2Delete);
					jQ("#allownshareinvite_title").show();
					jQ("#patch_cancelalert").hide().unbind("click");
				}else if(clickonclz=='privateon'){
					jQ("#patch_del_btn").show().unbind("click").bind("click",selected2Delete);
					jQ("#allownshareinvite_title").show();
					jQ("#patch_cancelalert").hide().unbind("click");
				}else if(clickonclz=='shareon'){
					jQ("#patch_del_btn").hide().unbind("click");
					jQ("#allownshareinvite_title").show();
					jQ("#patch_cancelalert").hide().unbind("click");
				}else if(clickonclz=='memoon'){
					jQ("#patch_del_btn").show().unbind("click").bind("click",selected2Delete);
					jQ("#memo_title").show();
					jQ("#patch_cancelalert").hide().unbind("click");
				}else if(clickonclz=='inviteon'){
					jQ("#patch_del_btn").show().unbind("click").bind("click",selected2Delete);
					jQ("#allownshareinvite_title").show();
					jQ("#patch_cancelalert").hide().unbind("click");
				}else if(clickonclz=='alerton'){
					jQ("#patch_del_btn").show().unbind("click").bind("click",selected2Delete);
					jQ("#patch_cancelalert").show().unbind("click").bind("click",selected2CancelAlert);
					jQ("#alert_title").show();
				}else if(clickonclz=='cacheon'){
					window.location.href=jQ("#ctxVal").val()+"/myclip/clip_cache.html";
				}else if(clickonclz=='recycleon'){
					window.location.href=jQ("#ctxVal").val()+"/myclip/clip_recycle.html";
				}
				loadMainpartRecords();
				var month=eval(jQ("#mainpart_list_content").data("month"));
				var year=eval(jQ("#mainpart_list_content").data("year"));
				var date=eval(jQ("#mainpart_list_content").data("date"));
				getEventsByMonth(year, month, true, date);
			}
		}
	});
	
	jQ("#viewopt").dialog({
		modal: true,
		bgiframe: true,
		autoOpen: false,
		closeOnEscape:false,
		draggable:false,
		height:200,
		buttons: {
			
			"确定": function() {
				var opt=jQ("#viewopt");
				var triggerfun=opt.data("function");
				opt.trigger(triggerfun);
				opt.removeData("function");
				jQ("#viewopt_p").hide();
				jQ("#viewopt_img").show();
				activeBtnOnDialog("viewopt",false);
				//jQ(this).dialog('close');
			},
			"取消": function() {
				var viewopt=jQ("#viewopt");
				var triggerfun=jQ("#viewopt").data("function");
				viewopt.unbind(triggerfun);
				viewopt.find("input.eventid").val("");
				viewopt.removeData("function");
				jQ(this).dialog('close');
			}
		},
		close: function() {
			jQ("#viewopt_p").show();
			jQ("#viewopt_img").hide();
			activeBtnOnDialog("viewopt",true);
		},
		open:function(){
		}
	});
});
function analyzeUrl(){
	var searchcontent=getParameter("content");
	if(searchcontent==null||searchcontent.length==0||typeof(searchcontent)=='undefined'){
		jQ("#mainpart_list_content").data("searchcontent","");
	}else{
		jQ("#mainpart_list_content").data("searchcontent",decodeURI(searchcontent));
	}
	var href="";
	var paramStr=location.href;
	if(paramStr.indexOf("#")>0){
		href=paramStr.substring(paramStr.indexOf("#")+1);
    }
	if(jQ("#clipmanagehead li[queryby="+href+"]").length>0){
		if(href=="cache"||href=="recycle")
			return;
		else{
			jQ("#clipmanagehead li").each(function(){
				var queryby=jQ(this).attr("queryby");
				jQ(this).removeClass("clickon").removeClass(queryby+"on");
			});
			
			if(href=='own'||href=='share'){
				jQ("#allownshareinvite_title").show();
				jQ("#patch_cancelalert").hide().unbind("click");
			}else if(href=='memo'){
				jQ("#memo_title").show();
				jQ("#patch_cancelalert").hide().unbind("click");
			}else if(href=='invite'){
				jQ("#allownshareinvite_title").show();
				jQ("#patch_cancelalert").hide().unbind("click");
			}else if(href=='alert'){
				jQ("#alert_title").show();
				jQ("#patch_cancelalert").show().unbind("click").bind("click",selected2CancelAlert);
			}
			if(href!='share'){
				jQ("#patch_del_btn").show().unbind("click").bind("click",selected2Delete);
			}else{
				jQ("#patch_del_btn").hide().unbind("click");
			}
			jQ("#clipmanagehead li[queryby="+href+"]").addClass("clickon").addClass(href+"on");
		}
	}else{
		jQ("#patch_del_btn").show().unbind("click").bind("click",selected2Delete);
		jQ("#allownshareinvite_title").show();
	}
	
}
function initChooseDayBtn(){
	jQ("#chooseday-allclip").unbind("click").bind("click",function(){
		if(jQ(this).hasClass("allclipon"))
			return;
		else{
			var queryby=jQ("#clipmanagehead li.clickon").attr("queryby");
			var currentpage=0;
			jQ("#mainpart_list_content").data("currentpage",0);
			jQ("#mainpart_list_content").data("month",0);
			jQ("#mainpart_list_content").data("year",0);
			jQ("#mainpart_list_content").data("date",0);
			jQ("tr.monthcontent td[class$=clickon]").removeClass("clickon").removeClass("todayclickon").removeClass("otherclickon");
			jQ("#chooseday-todayclip").removeClass("todayclipon");
			jQ("#chooseday-allclip").addClass("allclipon");
			jQ("#cliplistrecordsstatus").data("isall",true);
			jQ("#cliplistrecordsstatus").data("istoday",false);
			jQ("#cliplistrecordsstatus").data("date",0);
			loadMainpartRecords();
			
		}
	});
	jQ("#chooseday-todayclip").unbind("click").bind("click",function(){
		if(jQ(this).hasClass("todayclipon"))
			return;
		else{
			var toyear=eval(jQ("#smallcalendar").data("toyear"));
			var tomonth=eval(jQ("#smallcalendar").data("tomonth"));
			var todate=eval(jQ("#smallcalendar").data("todate"));
			getEventsByMonth(toyear,tomonth,true,todate);
			var queryby=jQ("#clipmanagehead li.clickon").attr("queryby");
			var currentpage=0;
			jQ("#mainpart_list_content").data("currentpage",0);
			jQ("#mainpart_list_content").data("month",tomonth);
			jQ("#mainpart_list_content").data("year",toyear);
			jQ("#mainpart_list_content").data("date",todate);
			jQ("tr.monthcontent td[class$=clickon]").removeClass("clickon").removeClass("todayclickon").removeClass("otherclickon");
			jQ("#chooseday-allclip").removeClass("allclipon");
			jQ("#chooseday-todayclip").addClass("todayclipon");
			jQ("#cliplistrecordsstatus").data("istoday",true);
			jQ("#cliplistrecordsstatus").data("isall",false);
			jQ("#cliplistrecordsstatus").data("date",0);
			loadMainpartRecords();
		}
	});
}

function getEventsByMonth(yearNum,monthNum,isneedclickon,date){
	jQ("#loadingui").show();
	var queryby=jQ("#clipmanagehead li.clickon").attr("queryby");
	var searchcontent=jQ("#mainpart_list_content").data("searchcontent");
	jQ.ajax({
		type: "POST",
		url:"calendarAjax!getClipManageEventsByMonth.action",
		data:{
			year:eval(yearNum),
			month:eval(monthNum),
			queryby:queryby,
			content:searchcontent
		},
		success:function(data){
			var toyear=eval(jQ(data).find("year").text());
			var tomonth=eval(jQ(data).find("month").text());
			var todate=eval(jQ(data).find("dayofmonth").text());
			jQ("#smallcalendar").data("toyear",toyear);
			jQ("#smallcalendar").data("tomonth",tomonth);
			jQ("#smallcalendar").data("todate",todate);
			
			var year_month=jQ(data).find("year_month").attr("value");
			var year=eval(year_month.split("_")[0]);
			var month=eval(year_month.split("_")[1]);
			jQ("#calendar_monthcontrolbar").data("currentyear",year);
			jQ("#calendar_monthcontrolbar").data("currentmonth",month);
			jQ("#mouth_fun_view_year option[value='"+year+"']").attr("selected",true);
			jQ("#mouth_fun_view_month option[value='"+(month)+"']").attr("selected",true);
			
			var firstDateOfMonth=new Date(year,month,1);
			var week2=firstDateOfMonth.getDay();
			var week1=0;
			var startdate=new Date(year,month,1);
			if(week2>week1){
				startdate.setDate(firstDateOfMonth.getDate() -week2);
			}
			
			var endyear,endmonth;
			if(month==11){
				endmonth=0;
				endyear=year+1;
			}else{
				endmonth=month+1;
				endyear=year;
			}
			
			var endDateOfMonth=new Date(endyear,endmonth,1);
			endDateOfMonth.setDate(endDateOfMonth.getDate() -1);
			var week6=6;
			var week5=endDateOfMonth.getDay();
			
			
			var enddate=new Date(endyear,endmonth,1);
			enddate.setDate(enddate.getDate() -1);
			if(week5<week6){
				enddate.setDate(endDateOfMonth.getDate()+ (week6-week5));
			}
			var index=0;
			var tY=toyear;
			var tM=tomonth;
			var tD=todate;
			
			while(startdate.getTime()<=enddate.getTime()){
				var monthdayObj=jQ("#tdmonth"+index);
				monthdayObj.attr("title",startdate.pattern("yyyy年MM月dd日"));
				var key="month"+startdate.pattern("MMdd");
				monthdayObj.removeClass();
				monthdayObj.addClass("month"+index);
				monthdayObj.data("date",startdate.getTime());
				var obj=jQ(data).find(key);
				var isThisMonth=eval(obj.find("isThisMonth").text());
				var eventsize=eval(obj.find("eventsize").text());
				var memosize=eval(obj.find("memosize").text());
				var alerteventsize=eval(obj.find("alerteventsize").text());
				var invitesize=eval(obj.find("invitesize").text());
				
				var startsharesize=eval(obj.find("startsharesize").text());
				var endsharesize=eval(obj.find("endsharesize").text());
				monthdayObj.data("alerteventsize",alerteventsize);
				var isholiday=eval(obj.attr("holiday"));
				var weeknum=eval(obj.find("weeknum").text());
				var weekofmonth=eval(obj.find("weekofmonth").text());
				var weekday=eval(obj.find("weekday").text());
				var lunartxt=obj.find("lunartxt").text();
				if(!isThisMonth){
					monthdayObj.addClass("other").attr("classmodel","other");
					if(isneedclickon&&startdate.getFullYear()==yearNum&&startdate.getMonth()==monthNum&&startdate.getDate()==date){
						monthdayObj.addClass("otherclickon");
					}
				}else{
					if(isneedclickon&&startdate.getFullYear()==yearNum&&startdate.getMonth()==monthNum&&startdate.getDate()==date){
						monthdayObj.addClass("clickon");
					}
				}
				if(isholiday){
					monthdayObj.addClass("holiday");
				}
				if(eventsize>0){
					monthdayObj.find("div.eventsign").show();
				}else{
					monthdayObj.find("div.eventsign").hide();
				}
				jQ("#tdmonth"+index+" div.sun").empty().append(startdate.getDate());
				
				jQ("#tdmonth"+index+" div.lunar").empty().append(lunartxt);
				var year=startdate.getFullYear();
				if(year==tY && startdate.getMonth()==tM && startdate.getDate()==tD){
					monthdayObj.removeClass().addClass("today");
					if(isneedclickon&&tD==date){
						monthdayObj.addClass("todayclickon");
					}
				}
				index++;
				startdate.setDate(startdate.getDate() +1);
			}
			if(index==28){
				jQ("#monthlast1").hide().removeClass();
				jQ("#monthlast2").hide().removeClass();
			}else if(index==35){
				jQ("#monthlast1").show().addClass("monthcontent");
				jQ("#monthlast2").hide().removeClass();
			}else{
				jQ("#monthlast1").show().addClass("monthcontent");
				jQ("#monthlast2").show().addClass("monthcontent");
			}
			
			jQ("#mouth_fun_prevyear").unbind( "click" );
			jQ("#mouth_fun_prevmonth").unbind( "click" );
			jQ("#mouth_fun_nextyear").unbind( "click" );
			jQ("#mouth_fun_nextmonth").unbind( "click" );
			jQ("#mouth_fun_prevyear").one("click",prevYearClick);
			jQ("#mouth_fun_prevmonth").one("click",prevMonthClick);
			jQ("#mouth_fun_nextyear").one("click",nextYearClick);
			jQ("#mouth_fun_nextmonth").one("click",nextMonthClick);
			jQ("tr.monthcontent td").unbind("click").bind("click",function(){
				if(jQ(this).hasClass("clickon")||jQ(this).hasClass("todayclickon")||jQ(this).hasClass("otherclickon")){
					return;
				}else{
					jQ("tr.monthcontent td[class$=clickon]").removeClass("clickon").removeClass("todayclickon").removeClass("otherclickon");
					jQ("#chooseday-todayclip").removeClass("todayclipon");
					jQ("#chooseday-allclip").removeClass("allclipon");
					if(jQ(this).hasClass("other")){
						jQ(this).addClass("otherclickon");
						jQ("#cliplistrecordsstatus").data("istoday",false);
						jQ("#cliplistrecordsstatus").data("isall",false);
					}else if(jQ(this).hasClass("today")){
						jQ(this).addClass("todayclickon");
						jQ("#chooseday-todayclip").addClass("todayclipon");
						jQ("#cliplistrecordsstatus").data("isall",false);
						jQ("#cliplistrecordsstatus").data("istoday",true);
					}else{
						jQ(this).addClass("clickon");
						jQ("#cliplistrecordsstatus").data("istoday",false);
						jQ("#cliplistrecordsstatus").data("isall",false);
					}
					var datetime=eval(jQ(this).data("date"));
					var temp=new Date();
					temp.setTime(datetime);
					var year=temp.getFullYear();
					var month=temp.getMonth();
					var date=temp.getDate();
					jQ("#mainpart_list_content").data("month",month);
					jQ("#mainpart_list_content").data("year",year);
					jQ("#mainpart_list_content").data("date",date);
					jQ("#mainpart_list_content").data("currentpage",0);
					jQ("#cliplistrecordsstatus").data("date",datetime);
					loadMainpartRecords();
				}
			});
			setTimeout(function(){
				jQ("#loadingui").hide();
			},1000);
		}
	});
}

var PAGESIZE=15;
function loadMainpartRecords(){
	var queryby=jQ("#clipmanagehead li.clickon").attr("queryby");
	var currentpage=eval(jQ("#mainpart_list_content").data("currentpage"));
	var month=eval(jQ("#mainpart_list_content").data("month"));
	var year=eval(jQ("#mainpart_list_content").data("year"));
	var date=eval(jQ("#mainpart_list_content").data("date"));
	var searchcontent=jQ("#mainpart_list_content").data("searchcontent");
	jQ.ajax({
		type:"POST",
		url: "manageClipAjax!loadMainpartRecords.action",
		data:{
			queryby:queryby,
			currentpage:currentpage,
			year:year,
			month:month,
			date:date,
			content:searchcontent
		},
		success:function(data){
			orgClipListData(data,queryby);
			jQ("#loadingui").hide();
		}
	});
}

function orgClipListData(data,queryby){
	var invitetotalcount=eval(jQ(data).find("invitetotalcount").text());
	var alerttotalcount=eval(jQ(data).find("alerttotalcount").text());
	
	jQ("#invitecount").data("count",invitetotalcount);
	jQ("#alertcount").data("count",alerttotalcount);
	
	invitetotalcount=invitetotalcount>99?"99+":invitetotalcount;
	alerttotalcount=alerttotalcount>99?"99+":alerttotalcount;
	
	jQ("#invitecount>span.count").empty().append(invitetotalcount);
	jQ("#alertcount>span.count").empty().append(alerttotalcount);
	
	var currentpage=eval(jQ(data).find("currentpage").text());
	jQ("#mainpart_list_content").data("currentpage",currentpage);
	var totalcount=eval(jQ(data).find("totalcount").text());
	var pagecount=eval(jQ(data).find("pagecount").text());
	jQ("#mainpart_list_content").data("pagecount",pagecount);
	var currentrecordcount=eval(jQ(data).find("currentrecordcount").text());
	if(totalcount>1)
		jQ("b.clippage_currentrecordcount").empty().append(currentpage*PAGESIZE+1+"-"+(currentpage*PAGESIZE+currentrecordcount));
	else
		jQ("b.clippage_currentrecordcount").empty().append(totalcount);
	jQ("b.clippage_totalcount").empty().append(totalcount);
	var cliphtml="";
	if(jQ(data).find("ClipEvent").length==0){
		cliphtml="<tr><td class='check'></td><td class='content'><span class='null'>暂无内容</span></td></tr>";
		jQ("#mainpart_list_content").empty().append(cliphtml);
		initResultText();
		return;
	}
	var currentusertype=eval(jQ("#var_usertype").val());
	jQ(data).find("ClipEvent").each(function(){
		if(queryby=='own'){
			var id=eval(jQ(this).attr("id"));//
			var uid=jQ(this).find("unameid").text();//
			var userlogo=jQ(this).find("unamelogo").text();
			var title=jQ(this).find("title").text();//
			//var eventtype=jQ(this).find("eventtype").text();//
			var isshareaccept=eval(jQ(this).find("isshareaccept").text());//
			var isinviteevent=eval(jQ(this).find("isinviteevent").text());//
			var uname=jQ(this).find("uname").text();
			var reliedclip=eval(jQ(this).find("reliedclip").text());
			var timesituation=eval(jQ(this).find("timesituation").text());
			var cliptype=eval(jQ(this).find("cliptype").text());
			var starttime=eval(jQ(this).find("starttime").text());
			var endtime=eval(jQ(this).find("endtime").text());
			var isuserself=eval(jQ(this).attr("isuserself"));
			var processstatus=eval(jQ(this).find("processstatus").text());
			var iswholeday=eval(jQ(this).find("iswholeday").text());
			var deadlinetime=eval(jQ(this).find("deadlinetime").text());
			var createtime=eval(jQ(this).find("createtime").text());
			var isexpire=eval(jQ(this).find("isexpire").text());
			var clipstatus=eval(jQ(this).find("clipstatus").text());
			var shareid=jQ(this).find("shareid").text();
			var eventisinterested=eval(jQ(this).find("eventisinterested").text());
			var eventtype=eval(jQ(this).find("eventtype").text());
			var seid=eval(jQ(this).find("seid").text());
			
			var invitetime=jQ(this).find("invitetime").text();
			var hasinvitetime=false;
			
			if(typeof(invitetime)!='undefined'&&eval(invitetime)>0){
				hasinvitetime=true;
				invitetime=eval(invitetime);
			}
			cliphtml+="<tr id='"+queryby+"-"+id+"' cliptype="+cliptype+" isuserself="+isuserself+" shareid="+shareid+">";
				cliphtml+="<td class=\"check\">";
				cliphtml+="<div class=\"clip_checkbox\">";
				cliphtml+="</div>";
				cliphtml+="</td>";
				cliphtml+="<td class=\"content\">";
				if(eventisinterested){
					cliphtml+="<div class=\"share\">";
				}else{
					if(isuserself){
						cliphtml+="<div class=\"owner\">";
					}else{
						cliphtml+="<div class=\"other\">";
					}
				}
				cliphtml+="<span class=\"head\" style=\"background:url('"+userlogo+"');\" title=\""+uname+"\"></span>";
				if(reliedclip>0){
					var clipiscc=eval(jQ(this).find("clipiscc").text());
					if(clipiscc){
						cliphtml+="<span class=\"v_icon\" title='档期认证'></span>";
					}else
						cliphtml+="<span class=\"space\" ></span>";
				}else{
					if(currentusertype==2&&isuserself)
						cliphtml+="<span class=\"v_icon\" title='档期认证'></span>";
					else
						cliphtml+="<span class=\"space\" ></span>";
				}
				cliphtml+="<span class=\"time\">";
				cliphtml+="<span class=\"timevalue\">";
				if(hasinvitetime){
					cliphtml+="<b >开始于</b>";
					cliphtml+="<b class=\"first\">"+formateTitleTime(invitetime)+"</b>";
				}else{
					if(iswholeday){
						cliphtml+="<b >开始于</b>";
						cliphtml+="<b class=\"first\">"+formateTitleTime(starttime)+"</b>";
					}else{
						cliphtml+="<b class=\"first\">"+formateTitleTime(starttime)+"</b>";
						cliphtml+="<b class=\"second\">"+formateTitleTime(endtime)+"</b>";
					}
				}
				cliphtml+="</span>";
				cliphtml+="</span>";
				
				cliphtml+="<span class=\"title\">";
				if(cliptype==3){
					if(eventtype==2&&(seid==0||seid==reliedclip)){
						cliphtml+="&nbsp;";
					}else{
						var isconfirmevent=eval(jQ(this).find("isconfirmevent").text());
						if(isconfirmevent)
							cliphtml+="<i class='confirmstat'></i>";
						cliphtml+="<i class='invite'></i>";
					}
				}else if(cliptype==4){
					cliphtml+="<i class='request'></i>";
				}
				
				cliphtml+=title;
				cliphtml+="</span>";
				cliphtml+="<span class=\"createtime\" title='"+formateDetailTime(createtime)+"'>";
				cliphtml+=formatCreatetime(createtime);
				cliphtml+="</span>";
				cliphtml+="</div>";
				cliphtml+="</td>";
			cliphtml+="</tr>";
		}else if(queryby=='private'){
			var id=eval(jQ(this).attr("id"));//
			var uid=jQ(this).find("unameid").text();//
			var userlogo=jQ(this).find("unamelogo").text();
			var title=jQ(this).find("title").text();//
			var uname=jQ(this).find("uname").text();
			var reliedclip=eval(jQ(this).find("reliedclip").text());
			var cliptype=eval(jQ(this).find("cliptype").text());
			var starttime=eval(jQ(this).find("starttime").text());
			var endtime=eval(jQ(this).find("endtime").text());
			var isuserself=eval(jQ(this).attr("isuserself"));
			var processstatus=eval(jQ(this).find("processstatus").text());
			var iswholeday=eval(jQ(this).find("iswholeday").text());
			var createtime=eval(jQ(this).find("createtime").text());
			var isexpire=eval(jQ(this).find("isexpire").text());
			var clipstatus=eval(jQ(this).find("clipstatus").text());
			cliphtml+="<tr id='"+queryby+"-"+id+"' cliptype="+cliptype+" isuserself="+isuserself+">";
			cliphtml+="<td class=\"check\">";
			cliphtml+="<div class=\"clip_checkbox\">";
			cliphtml+="</div>";
			cliphtml+="</td>";
			cliphtml+="<td class=\"content\">";
			cliphtml+="<div class=\"owner\">";
			cliphtml+="<span class=\"head\" style=\"background:url('"+userlogo+"');\" title=\""+uname+"\"></span>";
			cliphtml+="<span class=\"space\" ></span>";
			cliphtml+="<span class=\"time\">";
			/*if(processstatus==-1){
				cliphtml+="<b class='clip_before' title='未开始'></b>";
			}else if(processstatus==0){
				cliphtml+="<b class='clip_ing' title='进行中'></b>";
			}else if(processstatus==1){
				cliphtml+="<b class=\"clip_over\" title='已结束'></b>";
			}else if(processstatus==2){
				cliphtml+="<b class=\"clip_stop\" title='已停止'></b>";
			}*/
			cliphtml+="<span class=\"timevalue\">";
			if(iswholeday){
				cliphtml+="<b >开始于</b>";
				cliphtml+="<b class=\"first\">"+formateTitleTime(starttime)+"</b>";
			}else{
				cliphtml+="<b class=\"first\">"+formateTitleTime(starttime)+"</b>";
				cliphtml+="<b class=\"second\">"+formateTitleTime(endtime)+"</b>";
			}
			cliphtml+="</span>";
			cliphtml+="</span>";
			cliphtml+="<span class=\"title\">";
			cliphtml+="&nbsp;";
			cliphtml+=title;
			cliphtml+="</span>";
			cliphtml+="<span class=\"createtime\" title='"+formateDetailTime(createtime)+"'>";
			cliphtml+=formatCreatetime(createtime);
			cliphtml+="</span>";
			cliphtml+="</div>";
			cliphtml+="</td>";
		cliphtml+="</tr>";
		}else if(queryby=='memo'){
			var id=eval(jQ(this).attr("id"));//
			var title=jQ(this).find("title").text();//
			var starttime=eval(jQ(this).find("starttime").text());
			var createtime=eval(jQ(this).find("createtime").text());
			var clocktime=eval(jQ(this).find("clocktime").text());
			var cliptype=eval(jQ(this).find("cliptype").text());
			var clockstr=clocktime>0?formateDetailTime(clocktime):"暂无";
			cliphtml+="<tr id='"+queryby+"-"+id+"' cliptype="+cliptype+">";
			cliphtml+="<td class=\"check\" valign=\"top\"><div class=\"memo_checkbox\"></div></td>";
			cliphtml+="<td class=\"content\" valign=\"top\">";
			cliphtml+="<div class=\"owner\">";
			cliphtml+="<span class=\"memotitle\">"+title+"</span>";
			cliphtml+="<span class=\"time\"><b class=\"memotime\">"+formateMemoTime(starttime)+"</b></span>";
			cliphtml+="<span class=\"linetime\" clocktime="+clocktime+"><span class=\"memoalert\">"+clockstr+"</span></span>";
			cliphtml+="<span class=\"createtime\">"+formatCreatetime(createtime)+"</span>";
			cliphtml+="<span class=\"memoedit\" onclick='memoeditclick(this);'></span>";
			cliphtml+="</div>";
			cliphtml+="</td>";
			cliphtml+="</tr>";
		}else if(queryby=='invite'){
			var id=eval(jQ(this).attr("id"));//
			var unameid=jQ(this).find("unameid").text();//
			var uname=jQ(this).find("uname").text();//
			var unamelogo=jQ(this).find("unamelogo").text();
			var title=jQ(this).find("title").text();//
			//var eventtype=jQ(this).find("eventtype").text();//
			var isinviteaccept=eval(jQ(this).find("isinviteaccept").text());//
			var reliedclip=eval(jQ(this).find("reliedclip").text());
			var timesituation=eval(jQ(this).find("timesituation").text());
			var cliptype=eval(jQ(this).find("cliptype").text());
			var starttime=eval(jQ(this).find("starttime").text());
			var endtime=eval(jQ(this).find("endtime").text());
			var isuserself=eval(jQ(this).attr("isuserself"));
			var processstatus=eval(jQ(this).find("processstatus").text());
			var iswholeday=eval(jQ(this).find("iswholeday").text());
			var deadlinetime=eval(jQ(this).find("deadlinetime").text());
			var createtime=eval(jQ(this).find("createtime").text());
			var isexpire=eval(jQ(this).find("isexpire").text());
			var clipstatus=eval(jQ(this).find("clipstatus").text());
			var shareid=jQ(this).find("shareid").text();
			var eventisinterested=eval(jQ(this).find("eventisinterested").text());
			var invitetime=jQ(this).find("invitetime").text();
			var hasinvitetime=false;
			if(typeof(invitetime)!='undefined'&&eval(invitetime)>0){
				hasinvitetime=true;
				invitetime=eval(invitetime);
			}
			cliphtml+="<tr id='"+queryby+"-"+id+"' cliptype="+cliptype+" isuserself="+isuserself+" shareid='"+shareid+"'>";
				cliphtml+="<td class=\"check\">";
				cliphtml+="<div class=\"clip_checkbox\">";
				cliphtml+="</div>";
				cliphtml+="</td>";
				cliphtml+="<td class=\"content\">";
				if(eventisinterested){
					cliphtml+="<div class=\"share\">";
				}else{
					cliphtml+="<div class=\"other\">";
				}
				cliphtml+="<span class=\"head\" style=\"background:url('"+unamelogo+"');\" title=\""+uname+"\"></span>";
				cliphtml+="<span class=\"space\"></span>";
				cliphtml+="<span class=\"time\">";
				cliphtml+="<span class=\"timevalue\">";
				if(hasinvitetime){
					cliphtml+="<b >开始于</b>";
					cliphtml+="<b class=\"first\">"+formateTitleTime(invitetime)+"</b>";
				}else{
					if(iswholeday){
						cliphtml+="<b >开始于</b>";
						cliphtml+="<b class=\"first\">"+formateTitleTime(starttime)+"</b>";
					}else{
						cliphtml+="<b class=\"first\">"+formateTitleTime(starttime)+"</b>";
						cliphtml+="<b class=\"second\">"+formateTitleTime(endtime)+"</b>";
					}
				}

				cliphtml+="</span>";
				cliphtml+="</span>";
				cliphtml+="<span class=\"title\"><i class=\"invite\"></i>"+title+"</span>";
				cliphtml+="<span class=\"createtime\">";
				cliphtml+=formatCreatetime(createtime);
				cliphtml+="</span>";
				cliphtml+="</div>";
				cliphtml+="</td>";
			cliphtml+="</tr>";
		}else if(queryby=='alert'){
			var id=eval(jQ(this).attr("id"));//
			var unameuid=jQ(this).find("unameid").text();//
			var unamelogo=jQ(this).find("unamelogo").text();
			var title=jQ(this).find("title").text();//
			var uname=jQ(this).find("uname").text();
			//var eventtype=jQ(this).find("eventtype").text();//
			var isinviteaccept=eval(jQ(this).find("isinviteaccept").text());//
			var reliedclip=eval(jQ(this).find("reliedclip").text());
			var timesituation=eval(jQ(this).find("timesituation").text());
			var cliptype=eval(jQ(this).find("cliptype").text());
			var starttime=eval(jQ(this).find("starttime").text());
			var endtime=eval(jQ(this).find("endtime").text());
			var isuserself=eval(jQ(this).attr("isuserself"));
			var processstatus=eval(jQ(this).find("processstatus").text());
			var iswholeday=eval(jQ(this).find("iswholeday").text());
			var deadlinetime=eval(jQ(this).find("deadlinetime").text());
			var createtime=eval(jQ(this).find("createtime").text());
			var isexpire=eval(jQ(this).find("isexpire").text());
			var clipstatus=eval(jQ(this).find("clipstatus").text());
			var clocktime=eval(jQ(this).find("clocktime").text());
			var shareid=jQ(this).find("shareid").text();
			var eventtype=eval(jQ(this).find("eventtype").text());
			var seid=eval(jQ(this).find("seid").text());
			var eventisinterested=eval(jQ(this).find("eventisinterested").text());
			var invitetime=jQ(this).find("invitetime").text();
			var hasinvitetime=false;
			if(typeof(invitetime)!='undefined'&&eval(invitetime)>0){
				hasinvitetime=true;
				invitetime=eval(invitetime);
			}
			cliphtml+="<tr id='"+queryby+"-"+id+"' cliptype="+cliptype+" isuserself="+isuserself+" shareid="+shareid+">";
				cliphtml+="<td class=\"check\">";
				cliphtml+="<div class=\"clip_checkbox\">";
				cliphtml+="</div>";
				cliphtml+="</td>";
				cliphtml+="<td class=\"content\">";
				if(cliptype==2)
					cliphtml+="<div class=\"owner\">";
				else{
					if(eventisinterested){
						cliphtml+="<div class=\"share\">";
					}else {
						cliphtml+="<div class=\"owner\">";
					}
				}
				if(cliptype==2){
					var currentuserurl=jQ("#var_usertype").data("smallurl");
					cliphtml+="<span class=\"head\" style=\"background:url('"+currentuserurl+"');\" title=\"我\"></span>";
				}else{
					cliphtml+="<span class=\"head\" style=\"background:url('"+unamelogo+"');\" title=\""+uname+"\"></span>";
				}
				if(eventtype==2&&(seid==0||seid==reliedclip)){
					cliphtml+="<span class=\"v_icon\" title='档期认证'></span>";
				}else{
					cliphtml+="<span class=\"space\"></span>";
				}
				cliphtml+="<span class=\"time\">";
				cliphtml+="<span class=\"timevalue\">";
				if(cliptype==2){
					cliphtml+="<b class=\"first\" style=\"margin-top: 7px; margin-left: 12px;\">"+formateMemoTime(starttime)+"</b>";
				}else{
					if(hasinvitetime){
						cliphtml+="<b >开始于</b>";
						cliphtml+="<b class=\"first\">"+formateTitleTime(invitetime)+"</b>";
					}else{
						if(iswholeday){
							cliphtml+="<b >开始于</b>";
							cliphtml+="<b class=\"first\">"+formateTitleTime(starttime)+"</b>";
						}else{
							cliphtml+="<b class=\"first\">"+formateTitleTime(starttime)+"</b>";
							cliphtml+="<b class=\"second\">"+formateTitleTime(endtime)+"</b>";
						}
					}
				}
				cliphtml+="</span>";
				cliphtml+="</span>";
				cliphtml+="<span class=\"title\">";
				if(cliptype==2){
					cliphtml+="<b>纪念日：</b>";
				}else if(cliptype==3){
					if(eventtype==2&&(seid==0||seid==reliedclip)){
						cliphtml+="&nbsp;";
					}else{
						var isconfirmevent=eval(jQ(this).find("isconfirmevent").text());
						if(isconfirmevent){
							cliphtml+="<i class=\"confirmstat\"></i>";
						}
						cliphtml+="<i class=\"invite\"></i>";
					}
				}else if(cliptype==4){
					cliphtml+="<i class=\"request\"></i>";
				}
				cliphtml+=title;
				cliphtml+="</span>";
				cliphtml+="<span class=\"createtime\">";
				cliphtml+=formateDetailTime(clocktime);
				cliphtml+="</span>";
				cliphtml+="</div>";
				cliphtml+="</td>";
			cliphtml+="</tr>";
		}
		
	});
	jQ("#mainpart_list_content").empty().append(cliphtml);
	/*jQ("input.per").click(function(event){
		event.stopPropagation();
	});*/
	jQ("#mainpart_list_content tr td.content>div>span.head").unbind("mouseover").bind("mouseover",mouseoverHead);
	jQ("#mainpart_list_content tr td.content>div>span.head").unbind("mouseout").bind("mouseout",mouseoutHead);
	jQ("#mainpart_list_content tr td.check").unbind("click").bind("click",checkLine);
	jQ("#mainpart_list_content tr td.content").unbind("click").bind("click",cliplist2detail);
	initPaging(currentpage,pagecount);
	initResultText();
}

function mouseoverHead(){
	var headobj=jQ(this);
	var name=headobj.attr("title");
	var obj_box = headobj;
	var obj_offset = obj_box.offset();
	var msg_box = jQ("#tooltip");
	jQ("#tooltip div.tooltip-inner").empty().append(name);
	var _top = obj_offset.top-20 ;
	var _left = obj_offset.left-7;
	msg_box.css({"top":_top+"px","left":_left+"px"}).show();
}

function mouseoutHead(){
	jQ("#tooltip").hide();
}

function memoeditclick(obj){
	var divobj=jQ(obj).parent();
	var editobj=divobj.find("span.edit")
	if(editobj.length>0){
		return;
	}else{
		var clocktime=eval(divobj.find("span.linetime").attr("clocktime"));
		var html="<span class='edit'>";
		html+=divobj.find("span.time").clone().html();
		html+="<input class='title' value='"+divobj.find("span.memotitle").text()+"'>";
		if(clocktime>0){
			html+="<span class=\"alerticon calerticon\" title=\"取消提醒\" ></span>";
			html+="<div class=\"alertinput\">";
			html+="<span class=\"alertinfo\">";
			html+=divobj.find("span.linetime span.memoalert").clone().text();
			html+="</span>";
			html+="</div>";
		}else{
			html+="<span class=\"alerticon\" title=\"设置提醒\" ></span>";
			html+="<div class=\"alertinput\">";
			html+="<span class=\"alerttxt\">提醒时间：</span>";
			html+="<span class=\"alertspan\">";
			html+="<input onfocus=\"jQ(this).blur();\" style=\"float: left;height: 13px;width: 90px;margin-right: 10px;\" class=\"input\">";
			html+="<div class=\"timebg hourbg\">";
			html+="<a onclick=\"hourminus(jQ(this).next());\" onmousedown=\"autohourminusdown(jQ(this).next());\" onmouseup=\"autohourminusup(jQ(this).next());\" class=\"minus\"></a>";
			html+="<input class=\"hminput\" onblur=\"hourinput(this);\" value=\"0\" maxlength=\"2\">";
			html+="<a onclick=\"hourplus(jQ(this).prev());\" onmousedown=\"autohourplusdown(jQ(this).prev());\" onmouseup=\"autohourplusup(jQ(this).prev());\" class=\"plus\"></a>";
			html+="</div>";
			html+="<span class=\"txt\">时</span>";
			html+="<div class=\"timebg minbg\">";
			html+="<a onclick=\"minminus(jQ(this).next());\" onmousedown=\"autominminusdown(jQ(this).next());\" onmouseup=\"autominminusup(jQ(this).next());\"  class=\"minus\"></a>";
			html+="<input class=\"hminput\" onblur=\"mininput(this);\" value=\"0\" maxlength=\"2\">";
			html+="<a onclick=\"minplus(jQ(this).prev());\" onmousedown=\"autominplusdown(jQ(this).prev());\" onmouseup=\"autominplusup(jQ(this).prev());\" class=\"plus\"></a>";
			html+="</div>";
			html+="<span class=\"txt\">分</span>";
			if(eval(jQ("#var_hasmobile").val()))
				html+="<span class=\"mobile_m\" onclick='changeMobileStatus(this)'></span>";
			html+="</span>";
			html+="</div>";
		}
		html+="<span class=\"editsave\" onclick=\"saveMemoEdit(this)\"></span>";
		html+="<span class=\"editcancel\" onclick=\"cancelMemoEdit(this)\"></span>";
		html+="</span>";
		divobj.append(html);
		divobj.find("input.input").datepicker({
			yearRange : '1950:2020',
			dateFormat:'yy-mm-dd',
			changeMonth:true,
			changeYear:true,
			beforeShow: function(i,e){  
				var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
				e.dpDiv.css('z-index', z);
				e.dpDiv.css('font', "14px \"Trebuchet MS\", sans-serif");
			}
		});
		divobj.parent().prev().addClass("memocheck");
		divobj.addClass("memoedit");
		divobj.find("span.alerticon").unbind("click").bind("click",function(){
			if(jQ(this).hasClass("calerticon")){
				var html="";
				html+="<span class=\"alerttxt\">提醒时间：</span>";
				html+="<span class=\"alertspan\">";
				html+="<input onfocus=\"jQ(this).blur();\" style=\"float: left;height: 13px;width: 90px;margin-right: 10px;\" class=\"input\">";
				html+="<div class=\"timebg hourbg\">";
				html+="<a onclick=\"hourminus(jQ(this).next());\" onmousedown=\"autohourminusdown(jQ(this).next());\" onmouseup=\"autohourminusup(jQ(this).next());\" class=\"minus\"></a>";
				html+="<input class=\"hminput\" onblur=\"hourinput(this);\" value=\"0\" maxlength=\"2\">";
				html+="<a onclick=\"hourplus(jQ(this).prev());\" onmousedown=\"autohourplusdown(jQ(this).prev());\" onmouseup=\"autohourplusup(jQ(this).prev());\" class=\"plus\"></a>";
				html+="</div>";
				html+="<span class=\"txt\">时</span>";
				html+="<div class=\"timebg minbg\">";
				html+="<a onclick=\"minminus(jQ(this).next());\" onmousedown=\"autominminusdown(jQ(this).next());\" onmouseup=\"autominminusup(jQ(this).next());\"  class=\"minus\"></a>";
				html+="<input class=\"hminput\" onblur=\"mininput(this);\" value=\"0\" maxlength=\"2\">";
				html+="<a onclick=\"minplus(jQ(this).prev());\" onmousedown=\"autominplusdown(jQ(this).prev());\" onmouseup=\"autominplusup(jQ(this).prev());\" class=\"plus\"></a>";
				html+="</div>";
				html+="<span class=\"txt\">分</span>";
				if(eval(jQ("#var_hasmobile").val()))
					html+="<span class=\"mobile_m\" onclick='changeMobileStatus(this)'></span>";
				html+="</span>";
				jQ(this).next().empty().append(html);
				jQ(this).next().find("input.input").datepicker({
					yearRange : '1950:2020',
					dateFormat:'yy-mm-dd',
					changeMonth:true,
					changeYear:true,
					beforeShow: function(i,e){  
						var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
						e.dpDiv.css('z-index', z);  
					}
				});
				jQ(this).removeClass("calerticon");
				jQ(this).next().data("hasalert",0);
			}else{
				jQ(this).next().children().show();
				jQ(this).addClass("calerticon");
				jQ(this).next().data("hasalert",1);
			}
			
		});
	}
}

function saveMemoEdit(obj){
	var divobj=jQ(obj).prev();
	var hasalert=eval(divobj.data("hasalert"));
	var ismobilenotice=0;
	if(eval(jQ("#var_hasmobile").val())&&hasalert){
		ismobilenotice=divobj.data("ismobilenotice");
	}
	var inputobj=divobj.prev().prev();
	var inputvalue=jQ(inputobj.val()).trim();
	if(inputvalue.length>50){
		alert("内容请控制在50字以内");
		return;
	}
	var alertlong=0;
	if(hasalert){
		var timeinput=jQ(divobj).find("input.input");
		var alertdateval=timeinput.val();
		if(alertdateval==null||alertdateval.length<=0){
			alert("请选择提醒的时间。");
			return;
		}
		var alertdate=timeinput.datepicker( "getDate" );
		var alerthour=eval(jQ("#alerthour").val());
		var alertmin=eval(jQ("#alertmin").val());
		alertdate.setHours(alerthour);
		alertdate.setMinutes(alertmin);
		alertlong=alertdate.getTime();
		var nowdate=new Date();
		if(alertlong<nowdate){
			alert("提醒的时间应该是将来的时间。");
			return;
		}
	}else
		alertlong=-1
	jQ.ajax({
		type: "POST",
		url:"eventAjax!updateMemoContent.action",
		data:{
			eventid:eventid,
			title:inputvalue,
			alerttime:alertlong,
			mobilenotice:ismobilenotice
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					jQ("li[eventid="+eventid+"] div.daycontent input:text").val(val);
					jQ("li[eventid="+eventid+"] div.daycontent input:hidden").val(val);
					obj.removeClass("edit");
					errorinfo.hide();
				}else{
					
				}
			}
		}
	});
	
}
function cancelMemoEdit(obj){
	var editobj=jQ(obj).parent();
	var divobj=editobj.parent();
	editobj.remove();
	divobj.parent().prev().removeClass("memocheck");
	divobj.removeClass("memoedit");
}

function changeMobileStatus(obj){
	if(jQ(obj).hasClass("mobile_m_on")){
		jQ(obj).parent().data("ismobilenotice",0);
		jQ(obj).attr("title","取消手机提醒");
	}else{
		jQ(obj).addClass("mobile_m_on");
		jQ(obj).parent().data("ismobilenotice",1);
		jQ(obj).attr("title","设置手机提醒");
	}
	
}

function cliplist2detail(event){
	var targetobj=event.target;
	if(!jQ(targetobj).hasClass("head")&&!jQ(targetobj).hasClass("name")){
		var trobj=jQ(this).parent();
		var cliptype=eval(trobj.attr("cliptype"));
		var isuserself=eval(trobj.attr("isuserself"));
		var idstr=trobj.attr("id");
		var idarr=idstr.split("-");
		if(idarr[0]!='memo'&&cliptype!=2){
			var queryby=jQ("#clipmanagehead li.clickon").attr("queryby");
			var month=eval(jQ("#mainpart_list_content").data("month"));
			var year=eval(jQ("#mainpart_list_content").data("year"));
			var date=eval(jQ("#mainpart_list_content").data("date"));
			var searchcontent=jQ("#mainpart_list_content").data("searchcontent");
			var shareid=trobj.attr("shareid");
			var eventid=idarr[1];
//			jQ.ajax({
//				type: "POST",
//				url:"eventAjax!setCalendarDetailQuery.action",
//				data:{
//					year:year,
//					month:month,
//					date:date,
//					queryby:queryby,
//					content:searchcontent
//				},
//				success:function(data){
					if(isuserself){
						window.open(jQ("#ctxVal").val()+"/myclip/clip_detail.html?eventid="+eventid);
					}else if(cliptype==3){
						window.open(jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+shareid);
					}
//				}
//			});
		}
	}
}

function initResultText(){
	var isall=eval(jQ("#cliplistrecordsstatus").data("isall"));
	var istoday=eval(jQ("#cliplistrecordsstatus").data("istoday"));
	var datetime=eval(jQ("#cliplistrecordsstatus").data("date"));
	var searchcontent=jQ("#mainpart_list_content").data("searchcontent");
	var result="";
	if(searchcontent!=null&&searchcontent.length>0&&typeof(searchcontent)!='undefined'){
		if(isall){
			result="搜索了\"<font>"+searchcontent+"</font>\"的<font > 全部 </font>";
		}else if(istoday){
			result="搜索了\"<font>"+searchcontent+"</font>\"的<font > 今日 </font>";
		}else{
			result="搜索了\"<font>"+searchcontent+"</font>\"的<font > "+formateTitleTime(datetime)+" </font>";
		}
	}else{
		if(isall){
			result="显示为<font> 全部 </font>";
		}else if(istoday){
			result="显示为<font> 今日 </font>";
		}else{
			result="显示为<font> "+formateTitleTime(datetime)+" </font>";
		}
	}
	var queryby=jQ("#clipmanagehead li.clickon").attr("queryby");
	if(queryby=="own"){
		result+="<font> 找乐子 </font>档期";
	}else if(queryby=="prvate"){
		result+="<font> 个人计划 </font>";
	}else if(queryby=="memo"){
		result+="<font> 纪念日 </font>";
	}else if(queryby=="invite"){
		result+="<font> 邀请 </font>档期";
	}else if(queryby=="alert"){
		result+="<font> 提醒 </font>档期";
	}
	jQ("#cliplistrecordsstatus").empty().append(result);
}

function initPaging(currentpage,pagec){
	jQ("#pagingcontent").empty();
	jQ("#pagingcount").empty();
	var pagecount=pagec;
	if(pagecount==1){
		jQ("#pagingcontent").hide();
		jQ("#pagecount").hide();
		return;
	}else{
		var pagemin=currentpage-2;
		var pagemax=currentpage+2;
		if(pagemin<0){
			pagemin=0;
		}
		if(pagemax>pagecount-1){
			pagemax=pagecount-1;
		}
		var html="";
		html+="<a page='first'><span >&lt;&lt;</span></a>";
		for(var i=pagemin;i<=pagemax;i++){
			if(i==currentpage){
				html+="<b ><span>"+(i+1)+"</span></b>";
			}else
				html+="<a page='"+i+"'><span>"+(i+1)+"</span></a>";
		}
		html+="<a page='last'><span >&gt;&gt;</span></a>";
		jQ("#pagingcontent").append(html);
		jQ("#pagingcontent a").unbind("click").bind("click",function(){
			var page=jQ(this).attr("page");
			var currentpage=0;
			if(page=="first"){
				currentpage=0;
			}else if(page=="last"){
				currentpage=pagecount-1;
			}else{
				currentpage=eval(page);
			}
			jQ("#mainpart_list_content").data("currentpage",currentpage);
			loadMainpartRecords();
			//loadAllMemo(currentpage);
		});
		jQ("#pagingcontent").show();
		jQ("#pagingcount").append("共有"+pagecount+"页").show();
	}
}

function sel_allclick(obj){
	var trlength=jQ("#mainpart_list_content tr").length;
	var ison=jQ(obj).hasClass("sel_allon");
	if(trlength==0){
		if(ison){
			jQ("a.sel_all").removeClass("sel_allon");
		}else{
			jQ("a.sel_all").addClass("sel_allon");
		}
	}else{
		if(ison){
			jQ("a.sel_all").removeClass("sel_allon");
			jQ("#mainpart_list_content tr td.check").each(function(){
				if(jQ(this).find("div").hasClass("check")){
					jQ(this).find("div").removeClass("check");
					var trobj=jQ(this).parent();
					trobj.data("check",false);
				}
			});
		}else{
			jQ("a.sel_all").addClass("sel_allon");
			jQ("#mainpart_list_content tr td.check").each(function(){
				if(!jQ(this).find("div").hasClass("check")){
					jQ(this).find("div").addClass("check");
					var trobj=jQ(this).parent();
					trobj.data("check",true);
				}
			});
		}
	}
}

function checkLine(){
	var trobj=jQ(this).parent().parent();
	if(jQ(this).find("div").hasClass("check")){
		jQ(this).find("div").removeClass("check");
		trobj.data("check",false);
	}else{
		jQ(this).find("div").addClass("check");
		trobj.data("check",true);
	}
}

function selected2CancelAlert(){
	var info="";
	var title="";
	if(jQ("#mainpart_list_content td.check div.check").length==0){
		alert("您还未选择任何档期");
		return;
	}
	info="您确定要取消这些档期提醒么？";
	title="批量取消档期提醒";
	
	var opt=jQ("#viewopt");
	opt.bind("patchCancelAlertEvent",patchCancelAlertEvent);
	opt.data("function","patchCancelAlertEvent")
	jQ("#viewopt_p").empty().append(info);
	jQ("#viewopt").dialog("option", "title", title);
	jQ("#viewopt").dialog("open");
}

function patchCancelAlertEvent(){
	
	jQ("#mainpart_list_content td.check div.check").each(function(){
		var trobj=jQ(this).parent().parent();
		var trid=trobj.attr("id");
		var eventid=eval(trid.split("-")[1]);
		jQ.ajax({
			type: "POST",
			url:"eventAjax!cancelClock.action",
			data:{
				eventid:eventid
			},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj['result']){
						jQ("#"+trid).remove();
					}else{
						
					}
				}
			}
		});
	});
	jQ("#viewopt").dialog("close");
	
	loadMainpartRecords();
}

function selected2Delete(){
	var info="";
	var title="";
	if(jQ("#mainpart_list_content td.check div.check").length==0){
		alert("您还未选择任何档期");
		return;
	}
	info="您确定要删除这些档期么？<p>分享档期将不被保存在回收站内";
	title="批量删除档期";
	
	var opt=jQ("#viewopt");
	opt.bind("patchDeleteEvent",patchDeleteEvent);
	opt.data("function","patchDeleteEvent")
	jQ("#viewopt_p").empty().append(info);
	jQ("#viewopt").dialog("option", "title", title);
	jQ("#viewopt").dialog("open");
	
}

function patchDeleteEvent(){
	var length=jQ("#mainpart_list_content td.check div.check");
	jQ("#mainpart_list_content td.check div.check").each(function(i){
		var trobj=jQ(this).parent().parent();
		var trid=trobj.attr("id");
		var eventid=eval(trid.split("-")[1]);
		jQ.ajax({
			type: "POST",
			url:"eventAjax!deleteEvent.action",
			data:{
				eventid:eventid
			},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj['result']){
						jQ("#"+trid).remove();
					}else{
						
					}
					if(i==length-1)
						loadMainpartRecords();
				}
			}
		});
	});
	jQ("#viewopt").dialog("close");
	
}

function prevYearClick(){
	var year=eval(jQ("#mouth_fun_view_year").val());
	year=year-1;
	var month=eval(jQ("#mouth_fun_view_month").val());
	jQ("#mouth_fun_view_year option[value='"+(year)+"']").attr("selected",true);
	jQ("#mouth_fun_view_year").trigger("change");
}
function prevMonthClick(){
	var year=eval(jQ("#mouth_fun_view_year").val());
	var month=eval(jQ("#mouth_fun_view_month").val());
	if(month==0){
		month=11;
		year=year-1;
	}else{
		month=month-1;
	}
	jQ("#mouth_fun_view_year option[value='"+year+"']").attr("selected",true);
	jQ("#mouth_fun_view_month option[value='"+month+"']").attr("selected",true);
	jQ("#mouth_fun_view_year").trigger("change");
}
function nextMonthClick(){
	var year=eval(jQ("#mouth_fun_view_year").val());
	var month=eval(jQ("#mouth_fun_view_month").val());
	if(month==11){
		month=0;
		year=year+1;
	}else{
		month=month+1;
	}
	jQ("#mouth_fun_view_year option[value='"+year+"']").attr("selected",true);
	jQ("#mouth_fun_view_month option[value='"+month+"']").attr("selected",true);
	jQ("#mouth_fun_view_year").trigger("change");
}
function nextYearClick(){
	var year=eval(jQ("#mouth_fun_view_year").val());
	year=year+1;
	var month=eval(jQ("#mouth_fun_view_month").val());
	jQ("#mouth_fun_view_year option[value='"+(year)+"']").attr("selected",true);
	jQ("#mouth_fun_view_year").trigger("change");
}
function changeMonthView(){
	var year=eval(jQ("#mouth_fun_view_year").val());
	var month=eval(jQ("#mouth_fun_view_month").val());
	var mainloadyear=eval(jQ("#mainpart_list_content").data("year"));
	var mainloadmonth=eval(jQ("#mainpart_list_content").data("month"));
	var mainloaddate=eval(jQ("#mainpart_list_content").data("date"));
	if(mainloadyear!=0&&mainloadmonth!=0&&mainloaddate!=0){
		if(year==mainloadyear&&month==mainloadmonth){
			getEventsByMonth(year, month,true,mainloaddate);
		}else{
			getEventsByMonth(year, month,false,0);
		}
	}else
		getEventsByMonth(year, month,false,0);
	
}


function formateDetailTime(daytime){
	var temp=new Date();
	temp.setTime(eval(daytime));
	return temp.pattern("yyyy-MM-dd HH:mm");
}

function formateTitleTime(daytime){
	var temp=new Date();
	temp.setTime(eval(daytime));
	return temp.pattern("yyyy年MM月dd日");
}

function formateMemoTime(daytime){
	var day=new Date();
	day.setTime(daytime);
	return day.pattern("MM月dd日");
}

